/*
 * @Author: sunzhijun 
 * @Date: 2019-10-30 15:22:30 
 * @Last Modified by: sunzhijun
 * @Last Modified time: 2020-03-26 09:48:47
 */

import {hrAjax as ajax, formatDate} from 'src/hrpub/common/utils/utils';

export default {
    name: 'main',
    data: {
        fromApprove: false,                         //是否来自审批中心
        language: {},                               // 多语
        context: {},
        pageInfo: {                                 //分页默认数据
            pageSize: 10,
            total: 10,
            pageIndex: 1
        },
        pageid: '',
        tableId: 'dataList',                        //列表areacode id
        cardId: 'dataBase',                         //卡片areacode id
        areaCode: 'dataBase,dataBefore,dataAfter', 
        isEdit: false,                              //是否修改态
        isVisiblePagination: false,                 //是否显示分页
        step: '0',                                  //保存的步骤
        isShowOrg: false,                           //是否显示组织信息
        orgValue: {},                               //组织信息
        isCardForm: false,                          //是否是cardForm页面
        formVisible: false,                         //新增时卡片页面的显示隐藏
        step: '0',                                   //新增保存时步骤默认为0
        showFlowModal: false,                       //流程历史
        isCardPaginationVisible: false,             //卡片分页显隐性
        cardPaginationStatus: 1,                    //1为修改，2为新增，3为删除
        isModifyEdit: false,
        formData: {},
        info2: null,
        orderStatus: ['-1', '3'],
        timeRange: 'oneWeek',
        time: {
            "beginTime":"",
            "billStatus":"all",
            "endTime":"",
            "time":"oneWeek"
        },
        timerRangeValue: [],
        nodeRefs: {},                                //此处是为了存refs
        H: '',
        isDone: false,  // 完成标志
        rollBackFlag: false,
        rollBackFlagBillCode: false,
        fileVisible: false
    },
    sync: {
        update(state, payload) {
            return {
                ...state,
                ...payload
            };
        }
    },
    async: {
        // 获取列表页数据
        getTableAction(dispatch, getState, payload){
            return ajax({
                url: '/nccloud/hrcm/ctrtmng/CtrtMngQueryListAction.do',
                body: payload
            })
        },
        // 获取卡片数据
        getFormAction(dispatch, getState, payload){
            return ajax({
                url: '/nccloud/hrcm/ctrtmng/CtrtMngQueryDetailAction.do',
                body: payload
            })
        },
        // 编辑前校验
        checkDataAction(dispatch, getState, payload){
            return ajax({
                url: '/nccloud/hrcm/ctrtmng/CtrtMngCheckDataPermissionAction.do',
                body: payload
            })  
        },
        // 保存
        saveDataAction(dispatch, getState, payload){
            return ajax({
                url: '/nccloud/hrcm/ctrtmng/CtrtMngUpdateSaveDataAction.do',
                body: payload
            })  
        },

        //新增下一步
        nextHandleAction(dispatch, getState, payload){
            return ajax({
                url: '/nccloud/hrcm/ctrtmng/CtrtMngDefaultDataInitAction.do',
                body: payload
            })
        },
        //新增保存
        newAddSaveAction(dispatch, getState, payload){
            return ajax({
                url: '/nccloud/hrcm/ctrtmng/CtrtMngSaveAction.do',
                body: payload
            })
        },
        //提交
        submitAction(dispatch, getState, payload){
            return ajax({
                url: '/nccloud/hrcm/ctrtmng/CtrtMngSubmitAction.do',
                body: payload
            })
        },
        //操作校验
        operationCheckout(dispatch, getState, payload){
            return ajax({
                url: '/nccloud/hrcm/ctrtmng/CtrtMngCheckDataPermissionAction.do',
                body: payload
            })
        },
        //撤回
        revokeAction(dispatch, getState, payload){
            return ajax({
                url: '/nccloud/hrcm/ctrtmng/CtrtMngRecallAction.do',
                body: payload
            })
        },
        //删除
        deleteAction(dispatch, getState, payload){
            return ajax({
                url: '/nccloud/hrcm/ctrtmng/CtrtMngDeleteAction.do',
                body: payload
            })
        },

        rollBackAction(dispatch, getState, payload){
            return ajax({
                url: '/nccloud/hrcm/common/CodeRollBackAction.do',
                body: payload
            })
        }
    }
};